home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7194 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: free1-slip207.tele.queensu.ca!user
  2. From: 3gl21@qlink.queensu.ca (Gregory Lo)
  3. Newsgroups: comp.windows.x.motif,comp.lang.c++
  4. Subject: Re: MOTIF Callbacks, C++ Member Functions - SOLVED
  5. Date: Wed, 21 Feb 1996 20:07:53 -0608
  6. Organization: Queen's University
  7. Distribution: inet
  8. Message-ID: <3gl21-2102962007530001@free1-slip207.tele.queensu.ca>
  9. References: <4f6oau$c4m@knot.queensu.ca> <4f9fbo$7ju@news1.halcyon.com> <4gbf05$6d8@rex.sfe.com.au> <4gc9p3$s7s@tech.cftnet.com> <4gfdgb$n2d@newdelph.cig.mot.com>
  10. NNTP-Posting-Host: free1-slip207.tele.queensu.ca
  11. X-Newsreader: Yet Another NewsWatcher 2.2.0b4
  12.  
  13. In article <4gfdgb$n2d@newdelph.cig.mot.com>, khosravn@rtsg.mot.com
  14. (Shahram Khosravani) wrote:
  15.  
  16. > In article <4gc9p3$s7s@tech.cftnet.com>, wcowley@cftnet.com (Wes Cowley)
  17. writes:
  18. > |> Paul Hatchman (paul@sfe.com.au) wrote:
  19. > |> : danubius@chinook.halcyon.com () writes:
  20. > |> : 
  21. > |> : >Wintermute  <3mal5@qlink.queensu.ca> wrote:
  22. > |> : >>
  23. > |> : >>The solution was to declare a static member function which is
  24. used as a 
  25. > |> : >>callback.  Since it is static, there is no 'this' pointer, and it
  26. works 
  27. > |> : >>fine.  To access the particular class instance, pass the 'this'
  28. pointer 
  29. > |> : >>as client data when installing the callback, and it will be available 
  30. > |> : >>when the static member function is called back.
  31. > I don't do much C++ these days, but I think that the 'this' pointer you
  32. > are passing in as client data, can only be used to access other static
  33. > data/function members. It can not access any non-static data members or call
  34. > any non-static methods. True/False ?
  35.  
  36. The 'this' pointer is a member of an object that points to the object
  37. itself.  It will also point to all the information needed to access and
  38. object's non-static members and methods as well as static ones.
  39.  
  40. Non-static methods require the 'this' pointer to be passed to them
  41. implicitly in order to refer to the object in question, and access other
  42. methods and members (non-static or otherwise).
  43.  
  44. However, since static members are not implicitly passed the 'this'
  45. pointer, they can normally only access other static members and methods. 
  46. Static members and methods exist independantly of *any* object, they
  47. belong to the object's class.  This is probably what you are thinking of.
  48.  
  49. Depending on your situation, you might have to typecast the 'this' pointer
  50. when you pass it as client data, and then typecast it back when you access
  51. it.
  52. Greg Lo
  53.